package com.sx.entity.user;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.sx.basic.BasicEntity;
import com.sx.basic.serializer.LongToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;

/**
 * @author AdinZ
 * @date 2020/11/18 13:50
 * 邀请码 {@linkplain UserEntity#getId() 一对多 } {@linkplain InviteCodeEntity#getUid() 用户id}
 *
 */
@Data
@TableName(value = "sx_user_invite")
@Entity
@Table(name = "sx_user_invite")
@ApiModel(value = "用户邀请码",description = "用户邀请码")
public class InviteCodeEntity extends BasicEntity {
    public static final String KEY="InviteCodeEntity";

    @Id @GeneratedValue
    @TableId(type = IdType.ASSIGN_ID)
    private Long id;

    @ApiModelProperty("用户id")
    @JSONField(serializeUsing = LongToStringSerializer.class)
    private long uid;

    /**
     * 字符编码用utf8mb4,排序规则 utf8mb4_bin 区分大小写
     */
    @ApiModelProperty("邀请码")
    @Column(length = 10)
    private String code;

    @ApiModelProperty(value = "创建时间")
    private long created=System.currentTimeMillis();

    @ApiModelProperty(value = "状态",allowableValues = "[1:可用,0:禁用]")
    private int state=1;

    //生成循环次数,记录生成效率
    private int cycle;
    //生成耗时, 记录生成效率
    private long genTime;

    public InviteCodeEntity(){

    }
    public InviteCodeEntity(long uid){
        this.uid=uid;
    }

}
